<template>
  <div>
    <el-container class="home-container">
      <!-- 头部区域 -->
      <el-header>
        <span class="titleQY">千艺发型室</span>
        <el-button type="info" @click="getout">退出</el-button>
      </el-header>
      <!-- 主体区域 -->
      <el-container>
        <!-- 左侧区域 -->
        <el-aside :width="isCollapse?'60px':'150px'">
          <div class="toggle-button" @click="toggleCollapse">|||</div>
          <el-menu :collapse-transition="true" :router="true" :default-active="activerouter">
            <el-menu-item index="/staff">
              <i class="el-icon-user"></i>
              <span slot="title" v-show="list">员工信息</span>
            </el-menu-item>
            <el-menu-item index="/vip">
              <i class="el-icon-coordinate"></i>
              <span slot="title" v-show="list">会员信息</span>
            </el-menu-item>
            <el-menu-item index="/business">
              <i class="el-icon-document"></i>
              <span slot="title" v-show="list">交易信息</span>
            </el-menu-item>
            <el-menu-item index="/monthEnd">
              <i class="el-icon-data-line"></i>
              <span slot="title" v-show="list" :class="{monthClass:monthColor}">月末总结</span>
            </el-menu-item>
          </el-menu>
          <div class="huitailang" v-show="shiutainang"><img src="../assets/img/huitailang.png" alt=""></div>
        </el-aside>
        <!-- 右侧区域 -->
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'Home',
  components: {
  },
  data () {
    return {
      isCollapse: false,
      shiutainang: true,
      list: true,
      monthColor: null,
      activerouter: '',
      winLocaName: window.location.pathname
    }
  },
  methods: {
    getout () {
      window.sessionStorage.clear()
      this.$router.push('/login')
      // 退出时清除localStorage中保存的数据
      localStorage.clear()
    },
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
      this.shiutainang = !this.shiutainang
      this.list = !this.list
    }
  },
  created () {
    if (window.location.pathname === '/TurNover' || window.location.pathname === '/StaffMon') {
      this.monthColor = true
    } else {
      this.monthColor = false
    }
  },
  mounted () {
    this.activerouter = window.location.pathname
  },
  watch: {
    '$route.path': {
      handler (newVal, oldVal) {
        if (newVal === '/TurNover' || newVal === '/StaffMon') {
          this.monthColor = true
        } else {
          this.monthColor = false
        }
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.el-header {
  // background-color: rgb(117, 190, 236);
  background-image: linear-gradient(#89c1e5, #c2dfc6, #f8d598, #eb909a);
  color: #000;
  line-height: 60px;
  .titleQY {
    font-size: 20px;
    font-weight: 600;
    background-image: linear-gradient(to right, orange, purple);
    -webkit-background-clip: text;
    color: transparent;
  }
  .el-button {
    float: right;
    margin-top: 9px;
    background-image: linear-gradient(to right, orange, purple);
    -webkit-background-clip: text;
    color: transparent;
  }
}
.el-container {
  height: 100vh;
  .el-aside {
    background-color: #d3dce6;
    color: #333;
    .toggle-button {
      height: 30px;
      line-height: 30px;
      cursor: pointer;
      text-align: center;
    }
    .el-menu {
      opacity: 0.4;
      .el-menu-item {
        width: 100%;

        i {
          margin-left: 18px;
        }
        span {
          margin-left: 12px;
        }
      }
    }
  }
  .el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
  }
}
.el-aside {
  background-image: linear-gradient(#eb909a, #4977b7, #1cc5e2, #1fd797);
}
.huitailang {
  width: 150px;
  position: absolute;
  bottom: 0;
  img {
    width: 100%;
  }
}
.monthClass {
  color: #3f91da;
}
</style>
